﻿Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics


Namespace Drawing___Graph
    Partial Public Class Program
        Const maxScore = 15
        ' This is run when the mainboard is powered up or reset. 
        Public Sub ProgramStarted()
            '*******************************************************************************************
            ' Hardware modules added in the Program.gadgeteer designer view are used by typing 
            ' their name followed by a period, e.g.  button.  or  camera.
            '
            ' Many hardware modules generate useful events. To set up actions for those events, use the 
            ' left dropdown box at the top of this code editing window to choose a hardware module, then
            ' use the right dropdown box to choose the event - an event handler will be auto-generated.
            '*******************************************************************************************/

            ' Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started")

            Dim scoreValues() As Integer = {4, 8, 1, 3, 6, 11, 5, 9}
            displayValues(scoreValues)
        End Sub

        Private Sub displayValues(ByVal numberArray() As Integer)
            ' number of numbers is the length of the array
            Dim arrayLength As Integer = numberArray.Length()
            ' width of each bar is the column width - divide display width by array length
            Dim columnWidth As Integer = CInt(display.Width / arrayLength)
            ' height of each column will depend on the number in the array
            Dim columnHeight As Integer
            ' the starting x coordinate for the rectangle (top left)
            Dim startX As Integer
            ' the starting y coordinate for the rectangle (top left)
            Dim startY As Integer

            For count As Integer = 0 To arrayLength - 1
                columnHeight = CInt(display.Height / maxScore * numberArray(count))
                startX = columnWidth * count
                startY = display.Height - columnHeight

                display.SimpleGraphics.DisplayRectangle(GT.Color.White, 1, GT.Color.White, startX, startY, columnWidth, columnHeight)


            Next
             


        End Sub


        ' If you want to do something periodically, declare a GT.Timer by uncommenting the below line
        '   and then use the dropdown boxes at the top of this window to generate a Tick event handler.
        ' Dim WithEvents timer As GT.Timer = new GT.Timer(1000)  ' every second (1000ms)

    End Class
End Namespace